﻿using System;

namespace Needle.Core.Injection
{
    /// <summary>
    /// Defines a name and an interface by which 
    /// an instance of the tagged class is designed to be exposed.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public class InstanceIdAttribute : Attribute
    {
        /// <summary>
        /// Initializes a new instance of the InstanceIdAttribute class.
        /// </summary>
        /// <param name="publicInterface">The ( assembly qualified ) type name of the public interface of the instance.</param>
        public InstanceIdAttribute(string publicInterface)
        {
            _PublicInterface = publicInterface;
        }
        /// <summary>
        /// Initializes a new instance of the InstanceIdAttribute class.
        /// </summary>
        /// <param name="publicInterface">The type of the public interface of the instance.</param>
        public InstanceIdAttribute(Type publicInterface)
        {
            _PublicInterface = publicInterface.AssemblyQualifiedName;
        }
        /// <summary>
        /// Initializes a new instance of the InstanceIdAttribute class.
        /// </summary>
        /// <param name="name">The name of the instance</param>
        /// <param name="publicInterface">The type of the public interface of the instance.</param>
        public InstanceIdAttribute(string name, Type publicInterface)
        {
            _Name = name;
            _PublicInterface = publicInterface.AssemblyQualifiedName;
        }
        /// <summary>
        /// Initializes a new instance of the InstanceIdAttribute class.
        /// </summary>
        /// <param name="name">The name of the instance</param>
        /// <param name="publicInterface">The ( assembly qualified ) type name of the public interface of the instance.</param>
        public InstanceIdAttribute(string name, string publicInterface)
        {
            _Name = name;
            _PublicInterface = publicInterface;
        }

        private string _Name=null;
        /// <summary>
        /// The name of the instance
        /// </summary>
        public string Name
        {
            get { return _Name; }
        }

        private string _PublicInterface=null;
        /// <summary>
        /// The ( assembly qualified ) interface type name of the instance.
        /// </summary>
        public string PublicInterface
        {
            get { return _PublicInterface; }
        }

    }
}
